package com.jmu.shape;

import java.util.ArrayList;
import java.util.Collections;

public class TestShape {
    public static void main(String[] args) {

        //创建对象
        Shape circle1 = new Circle(2);
        Shape circle2 = new Circle(3);
        Shape rectangle1 = new Rectangle(1,2);
        Shape rectangle2 = new Rectangle(2,3);
        Shape triangle1 = new Triangle(3,4,5);
        Shape triangle2 = new Triangle(6,8,10);

        ArrayList<Shape> list = new ArrayList<>();
        list.add(circle1);
        list.add(circle2);
        list.add(rectangle1);
        list.add(rectangle2);
        list.add(triangle1);
        list.add(triangle2);

        System.out.printf("排序前的面积顺序：\n");
        for (Shape s:list
             ) {
            System.out.println(s.getArea());
        }

        Collections.sort(list);

        System.out.println("排序后的面积顺序：\n");
        for (Shape s:list
             ) {
            System.out.println(s.getArea());
        }
    }
}
